const net = require('net');
// import { net } from "net"
const server = net.createServer((socket) => {
    console.log('客户端已连接');

    socket.on('data', (data) => {
        console.log(data.toString());
        socket.write('你好，客户端！');
    });

    socket.on('end', () => {
        console.log('客户端已断开连接');
    });
});

server.listen(8080, () => {
    console.log('TCP服务器在8080端口监听');
});
